using System;
using System.Collections.Generic;
using System.Text;

namespace Pampa.Common.Utils
{
    public class Url
    {
        private string pageName;
        private SortedList<string, object> arguments;

        public Url(string pageName)
        {
            this.pageName = pageName;
            this.arguments = new SortedList<string, object>();
        }

        public SortedList<string, object> Arguments
        {
            get { return arguments; }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            bool thereAreParams = false;
            
            sb.Append(pageName);

            foreach (KeyValuePair<string, object> argument in arguments)
            {
                if (thereAreParams)
                    sb.Append("&");
                else
                    sb.Append("?");

                sb.Append(argument.Key + "=" + argument.Value.ToString());
                thereAreParams = true;
            }

            return sb.ToString();
        }
    }
}
